cmake build system: visiblity support for clang
[supercollider.git] / Help / UGens / Synth control / Control.html
blobcadd304b01c09d7cac1f527261762046c89beaba
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <meta http-equiv="Content-Style-Type" content="text/css">
6 <title></title>
7 <meta name="Generator" content="Cocoa HTML Writer">
8 <meta name="CocoaVersion" content="1038.25">
9 <style type="text/css">
10 p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
11 p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
12 p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #002fe0}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
14 p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #0b28c6}
15 p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000; min-height: 12.0px}
16 p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #cd1612}
17 p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000}
18 p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
19 p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #00831b}
20 p.p11 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica; min-height: 14.0px}
21 p.p12 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica}
22 p.p13 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica}
23 p.p14 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco}
24 p.p15 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco; min-height: 12.0px}
25 p.p16 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica; min-height: 17.0px}
26 span.s1 {font: 18.0px Helvetica}
27 span.s2 {color: #000000}
28 span.s3 {color: #0021e7}
29 span.s4 {color: #0026b4}
30 span.s5 {color: #002fe0}
31 span.s6 {color: #00831b}
32 span.s7 {color: #0b28c6}
33 span.s8 {font: 12.0px Helvetica}
34 span.s9 {color: #1135f9}
35 span.s10 {color: #00831c}
36 span.s11 {color: #0b28c5}
37 span.s12 {font: 9.0px Monaco}
38 span.Apple-tab-span {white-space:pre}
39 </style>
40 </head>
41 <body>
42 <p class="p1"><span class="s1"><b>Control<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b></span><b>ugen that can be set externally</b></p>
43 <p class="p2"><br></p>
44 <p class="p3"><span class="s2"><b>Inherits from: </b><a href="../../Core/Object.html"><span class="s3"><b>Object</b></span></a></span><span class="s4"><b> : </b><a href="../../Core/Kernel/AbstractFunction.html"><span class="s5"><b>AbstractFunction</b></span></a><b> : </b><a href="../UGen.html"><span class="s5"><b>UGen</b></span></a><b> :</b></span><span class="s2"><b> </b><a href="../Multichannel/MultiOutUGen.html"><span class="s3"><b>MultiOutUGen</b></span></a></span></p>
45 <p class="p2"><br></p>
46 <p class="p1">A Control is a UGen that can be set and routed externally to interact with a running <a href="../../ServerArchitecture/Synth.html"><span class="s4">Synth</span></a>.</p>
47 <p class="p1">Typically, Controls are created from the arguments of a <a href="../../ServerArchitecture/SynthDef.html"><span class="s4">SynthDef</span></a> function.</p>
48 <p class="p2"><br></p>
49 <p class="p1">related subclasses are: TrigControl, LagControl.</p>
50 <p class="p1">For a more concise combination of name, default value and lag, see <a href="NamedControl.html"><span class="s4">NamedControl</span></a><span class="Apple-converted-space"> </span></p>
51 <p class="p2"><br></p>
52 <p class="p1">The rate may be either .kr (continous control rate signal), .ar (audio rate) or .ir (a static value, set at the time the synth starts up, and subsequently unchangeable).</p>
53 <p class="p2"><br></p>
54 <p class="p1"><b>Control.ar(values)</b></p>
55 <p class="p1"><b>Control.kr(values)</b></p>
56 <p class="p1"><b>Control.ir(values)</b></p>
57 <p class="p2"><br></p>
58 <p class="p1"><b>*names(names)</b> <span class="Apple-tab-span"> </span>adds control names to the SynthDef.</p>
59 <p class="p2"><br></p>
60 <p class="p4"><span class="Apple-tab-span"> </span>(</p>
61 <p class="p5"><span class="s2"><span class="Apple-tab-span"> </span></span>SynthDef<span class="s2">(</span><span class="s6">\help_Control</span><span class="s2">, { </span>| freq = 200 |</p>
62 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
63 <p class="p7"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>freq.inspect; </span>// at the time of compiling the def</p>
64 <p class="p6"><span class="Apple-tab-span"> </span></p>
65 <p class="p8"><span class="Apple-tab-span"> </span>}).add</p>
66 <p class="p4"><span class="s2"><span class="Apple-tab-span"> </span></span>);</p>
67 <p class="p9"><span class="Apple-tab-span"> </span></p>
68 <p class="p7"><span class="s2"><span class="Apple-tab-span"> </span></span>// synonym:</p>
69 <p class="p8"><span class="Apple-tab-span"> </span>(</p>
70 <p class="p10"><span class="s2"><span class="Apple-tab-span"> </span></span><span class="s7">SynthDef</span><span class="s2">(</span>\help_Control<span class="s2">, {</span></p>
71 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
72 <p class="p7"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s6">\freq</span><span class="s2">.kr(200).inspect; </span>// at the time of compiling the def</p>
73 <p class="p6"><span class="Apple-tab-span"> </span></p>
74 <p class="p8"><span class="Apple-tab-span"> </span>}).add</p>
75 <p class="p8"><span class="Apple-tab-span"> </span>);</p>
76 <p class="p2"><br></p>
77 <p class="p1">What is passed into the ugenGraph function is an <a href="../Multichannel/OutputProxy.html"><span class="s4">OutputProxy</span></a>, and its source is a Control. The main explicit use of Control is to allow Arrays to be sent to running Synths:</p>
78 <p class="p9"><br></p>
79 <p class="p7"><span class="s2"><span class="Apple-tab-span"> </span></span>// a synth def that has 4 partials</p>
80 <p class="p8"><span class="Apple-tab-span"> </span>(</p>
81 <p class="p8"><span class="Apple-tab-span"> </span><span class="s7">SynthDef</span>(<span class="s6">\help_Control</span>, { <span class="s7">arg</span> out=0, i_freq;</p>
82 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s7">var</span> klank, harm, amp, ring;</p>
83 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
84 <p class="p7"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// harmonics</p>
85 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>harm = <span class="s7">Control</span>.names([<span class="s6">\harm</span>]).ir(<span class="s7">Array</span>.series(4, 1, 1).postln);</p>
86 <p class="p7"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// amplitudes</p>
87 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>amp = <span class="s7">Control</span>.names([<span class="s6">\amp</span>]).ir(<span class="s7">Array</span>.fill(4, 0.05));</p>
88 <p class="p7"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// ring times</p>
89 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>ring = <span class="s7">Control</span>.names([<span class="s6">\ring</span>]).ir(<span class="s7">Array</span>.fill(4, 1));</p>
90 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
91 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>klank = <span class="s7">Klank</span>.ar(`[harm, amp, ring], { <span class="s7">ClipNoise</span>.ar(0.01) }.dup, i_freq);</p>
92 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
93 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s7">Out</span>.ar(out, klank);</p>
94 <p class="p8"><span class="Apple-tab-span"> </span>}).add;</p>
95 <p class="p8"><span class="Apple-tab-span"> </span>)</p>
96 <p class="p6"><span class="Apple-tab-span"> </span></p>
97 <p class="p8"><span class="Apple-tab-span"> </span>a = <span class="s7">Synth</span>(<span class="s6">\help_Control</span>, [<span class="s6">\i_freq</span>, 300, <span class="s6">\harm</span>, [1, 3.3, 4.5, 7.8]]);</p>
98 <p class="p8"><span class="Apple-tab-span"> </span>a.free;</p>
99 <p class="p8"><span class="Apple-tab-span"> </span>a = <span class="s7">Synth</span>(<span class="s6">\help_Control</span>, [<span class="s6">\i_freq</span>, 300, <span class="s6">\harm</span>, [2, 3, 4, 5]]);</p>
100 <p class="p8"><span class="Apple-tab-span"> </span>a.free;</p>
101 <p class="p6"><span class="Apple-tab-span"> </span></p>
102 <p class="p8"><span class="s8"><span class="Apple-tab-span"> </span></span>(</p>
103 <p class="p10"><span class="s2"><span class="Apple-tab-span"> </span></span><span class="s7">SynthDef</span><span class="s2">(</span>\help_Control_Sines<span class="s2">, { </span><span class="s7">arg</span><span class="s2"> out=0;</span></p>
104 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s7">var</span> sines, control, numsines;</p>
105 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>numsines = 20;</p>
106 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>control = <span class="s7">Control</span>.names(<span class="s6">\array</span>).kr(<span class="s7">Array</span>.rand(numsines, 400.0, 1000.0));</p>
107 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>sines = <span class="s7">Mix</span>(<span class="s7">SinOsc</span>.ar(control, 0, numsines.reciprocal)) ;</p>
108 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s7">Out</span>.ar(out, sines ! 2);</p>
109 <p class="p8"><span class="Apple-tab-span"> </span>}).add</p>
110 <p class="p8"><span class="Apple-tab-span"> </span>)</p>
111 <p class="p6"><span class="Apple-tab-span"> </span></p>
112 <p class="p10"><span class="s2"><span class="Apple-tab-span"> </span>b = </span><span class="s7">Synth</span><span class="s2">(</span>\help_Control_Sines<span class="s2">);</span></p>
113 <p class="p8"><span class="Apple-tab-span"> </span>b.setn(<span class="s6">\array</span>, <span class="s7">Array</span>.rand(20, 200, 1600));</p>
114 <p class="p8"><span class="Apple-tab-span"> </span>b.setn(<span class="s6">\array</span>, <span class="s7">Array</span>.rand(20, 200, 1600));</p>
115 <p class="p6"><span class="Apple-tab-span"> </span></p>
116 <p class="p6"><span class="Apple-tab-span"> </span></p>
117 <p class="p6"><span class="Apple-tab-span"> </span></p>
118 <p class="p8"><span class="Apple-tab-span"> </span>(</p>
119 <p class="p8"><span class="Apple-tab-span"> </span><span class="s7">SynthDef</span>(<span class="s6">\help_Control_DynKlank</span>, { <span class="s7">arg</span> out=0, freq = 440;</p>
120 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s7">var</span> klank, harm, amp, ring;</p>
121 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
122 <p class="p7"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// harmonics</p>
123 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>harm = <span class="s7">Control</span>.names(<span class="s6">\harm</span>).kr(<span class="s7">Array</span>.series(4, 1, 1));</p>
124 <p class="p7"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// amplitudes</p>
125 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>amp = <span class="s7">Control</span>.names(<span class="s6">\amp</span>).kr(<span class="s7">Array</span>.fill(4, 0.05));</p>
126 <p class="p7"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// ring times</p>
127 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>ring = <span class="s7">Control</span>.names(<span class="s6">\ring</span>).kr(<span class="s7">Array</span>.fill(4, 1));</p>
128 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>klank = <span class="s7">DynKlank</span>.ar(`[harm, amp, ring], {<span class="s7">ClipNoise</span>.ar(0.003)}.dup, freq);</p>
129 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s7">Out</span>.ar(out, klank);</p>
130 <p class="p8"><span class="Apple-tab-span"> </span>}).add</p>
131 <p class="p8"><span class="Apple-tab-span"> </span>)</p>
132 <p class="p6"><span class="Apple-tab-span"> </span></p>
133 <p class="p10"><span class="s2"><span class="Apple-tab-span"> </span>a = </span><span class="s7">Synth</span><span class="s2">(</span>\help_Control_DynKlank<span class="s2">, [</span>\freq<span class="s2">, 300]);</span></p>
134 <p class="p10"><span class="s2"><span class="Apple-tab-span"> </span>b = </span><span class="s7">Synth</span><span class="s2">(</span>\help_Control_DynKlank<span class="s2">, [</span>\freq<span class="s2">, 400]);</span></p>
135 <p class="p6"><span class="Apple-tab-span"> </span></p>
136 <p class="p6"><span class="Apple-tab-span"> </span></p>
137 <p class="p8"><span class="Apple-tab-span"> </span>a.setn(<span class="s6">\harm</span>,   <span class="s7">Array</span>.rand(4, 1.0, 4.7))</p>
138 <p class="p8"><span class="Apple-tab-span"> </span>a.setn(<span class="s6">\amp</span>, <span class="s7">Array</span>.rand(4, 0.005, 0.1))</p>
139 <p class="p8"><span class="Apple-tab-span"> </span>a.setn(<span class="s6">\ring</span>, <span class="s7">Array</span>.rand(4, 0.005, 1.0))</p>
140 <p class="p6"><span class="Apple-tab-span"> </span></p>
141 <p class="p8"><span class="Apple-tab-span"> </span>b.setn(<span class="s6">\harm</span>,   <span class="s7">Array</span>.rand(4, 1.0, 4.7))</p>
142 <p class="p8"><span class="Apple-tab-span"> </span>b.setn(<span class="s6">\amp</span>, <span class="s7">Array</span>.rand(4, 0.005, 0.1))</p>
143 <p class="p8"><span class="Apple-tab-span"> </span>b.setn(<span class="s6">\ring</span>, <span class="s7">Array</span>.rand(4, 0.005, 1.0))</p>
144 <p class="p9"><br></p>
145 <p class="p9"><br></p>
146 <p class="p11"><br></p>
147 <p class="p12"><b>Symbols</b></p>
148 <p class="p11"><br></p>
149 <p class="p13"><span class="Apple-tab-span"> </span>Inside SynthDefs and UGen functions, symbols can be used to conventiently specify control inputs of different rates and with lags (see: <a href="ControlName.html"><span class="s9">ControlName</span></a><span class="s9">, </span>and<span class="s9"> <a href="../../Core/Symbol.html">Symbol</a>)</span></p>
150 <p class="p11"><span class="Apple-tab-span"> </span></p>
151 <p class="p11"><span class="Apple-tab-span"> </span></p>
152 <p class="p13"><span class="Apple-tab-span"> </span><b>kr(val, lag)</b></p>
153 <p class="p11"><span class="Apple-tab-span"> </span></p>
154 <p class="p13"><span class="Apple-tab-span"> </span>Return a control rate <a href="NamedControl.html"><span class="s9">NamedControl</span></a> input with a default value (<b>val</b>), and if supplied, with a <b>lag</b>. If val is an array, the control will be multichannel.</p>
155 <p class="p11"><span class="Apple-tab-span"> </span></p>
156 <p class="p14"><span class="Apple-tab-span"> </span>a = { <span class="s7">SinOsc</span>.ar(<span class="s10">\freq</span>.kr(440, 1.2)) }.play;</p>
157 <p class="p14"><span class="Apple-tab-span"> </span>a.set(<span class="s10">\freq</span>, 330);</p>
158 <p class="p14"><span class="Apple-tab-span"> </span>a.release;</p>
159 <p class="p14"><span class="s8"><span class="Apple-tab-span"> </span></span>a = { <span class="s11">SinOsc</span>.ar(<span class="s10">\freq</span>.kr([440, 460], 1.2)) }.play;</p>
160 <p class="p14"><span class="Apple-tab-span"> </span>a.setn(<span class="s10">\freq</span>, [330, 367]);</p>
161 <p class="p14"><span class="Apple-tab-span"> </span>a.release;</p>
162 <p class="p15"><span class="Apple-tab-span"> </span></p>
163 <p class="p13"><span class="s12"><span class="Apple-tab-span"> </span></span><b>ar(val, lag)</b></p>
164 <p class="p11"><span class="Apple-tab-span"> </span></p>
165 <p class="p13"><span class="Apple-tab-span"> </span>Return an audio rate <a href="NamedControl.html"><span class="s9">NamedControl</span></a><span class="s9"> </span>input with a default value (<b>val</b>), and if supplied, with a <b>lag</b>. If val is an array, the control will be multichannel.</p>
166 <p class="p16"><br></p>
167 <p class="p13"><span class="Apple-tab-span"> </span><b>ir(val)</b></p>
168 <p class="p11"><span class="Apple-tab-span"> </span></p>
169 <p class="p13"><span class="Apple-tab-span"> </span>Return an intitalization rate <a href="NamedControl.html"><span class="s9">NamedControl</span></a><span class="s9"> </span>input with a default value (<b>val</b>). If val is an array, the control will be multichannel.</p>
170 <p class="p11"><span class="s12"><span class="Apple-tab-span"> </span></span><span class="Apple-tab-span"> </span></p>
171 <p class="p13"><span class="Apple-tab-span"> </span><b>tr(val)</b></p>
172 <p class="p11"><span class="Apple-tab-span"> </span></p>
173 <p class="p13"><span class="Apple-tab-span"> </span>Return a TrigControl input with a default value (<b>val</b>). If val is an array, the control will be multichannel.</p>
174 <p class="p11"><span class="Apple-tab-span"> </span></p>
175 <p class="p14"><span class="Apple-tab-span"> </span>a = { <span class="s7">Ringz</span>.ar(<span class="s7">T2A</span>.ar(<span class="s10">\trig</span>.tr), <span class="s10">\freq</span>.kr(500, 1), 0.8) }.play;</p>
176 <p class="p14"><span class="Apple-tab-span"> </span>a.set(<span class="s10">\freq</span>, 330, <span class="s10">\trig</span>, 1);</p>
177 <p class="p14"><span class="Apple-tab-span"> </span>a.set(<span class="s10">\freq</span>, 830, <span class="s10">\trig</span>, 1);</p>
178 <p class="p14"><span class="Apple-tab-span"> </span>a.release;</p>
179 <p class="p15"><span class="Apple-tab-span"> </span></p>
180 <p class="p15"><span class="Apple-tab-span"> </span></p>
181 <p class="p15"><br></p>
182 <p class="p15"><br></p>
183 </body>
184 </html>